<%-- 
    Created on : 2019
    Author     : 黄忠
--%>

<%@page import="staffManager.StaffBean"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>个人信息管理系统->修改员工</title>
    <link rel="stylesheet" href="../CSS/infor.css">
</head>
<body bgcolor="CCCFFF">
    <%
        String userName=request.getParameter("userName");
        ArrayList staffslist=(ArrayList)session.getAttribute("staffslist");
    %>
    <br>
    <div id="showUpdate">
        <div style="float: left;width: 100%">
            <button style="float: right;" onclick="closeUpdate()">关闭</button>
        </div>
        <form action="http://localhost:8080/UpdateStaffServlet?userName=<%=userName%>" method="post">
            <table border="2"  cellspacing="0" cellpadding="0" style="width: 90%;" align="center">
                <%
                    if(userName!=null){
                        StaffBean nf = null;
                        for(int i=staffslist.size()-1;i>=0;i--) {
                            nf = (StaffBean) staffslist.get(i);
                            if(nf.getUserName().equals(userName)) break;
                        }
                %>
                <tr>
                    <td>用户账号</td>
                    <td><%=nf.getUserName()%></td>
                </tr>
                <tr>
                    <td>用户姓名</td>
                    <td><%=nf.getName()%></td>
                </tr>
                <tr>
                    <td>用户性别</td>
                    <td><%=nf.getSex()%></td>
                </tr>
                <tr>
                    <td>身份证</td>
                    <td><%=nf.getIdCard()%></td>
                </tr>
                <tr>
                    <td>用户民族</td>
                    <td><%=nf.getNation()%></td>
                </tr>
                <tr>
                    <td>用户学历</td>
                    <td>
                        <select name="edu" size="1">
                            <%if(nf.getEdu().equals("博士")){%>
                            <option value="博士" selected>博士</option>
                            <%}else{%>
                            <option value="博士">博士</option>
                            <%}%>
                            <%if(nf.getEdu().equals("硕士")){%>
                            <option value="硕士" selected>硕士</option>
                            <%}else{%>
                            <option value="硕士">硕士</option>
                            <%}%>
                            <%if(nf.getEdu().equals("本科")){%>
                            <option value="本科" selected>本科</option>
                            <%}else{%>
                            <option value="本科">本科</option>
                            <%}%>
                            <%if(nf.getEdu().equals("专科")){%>
                            <option value="专科" selected>专科</option>
                            <%}else{%>
                            <option value="专科">专科</option>
                            <%}%>
                            <%if(nf.getEdu().equals("高中")){%>
                            <option value="高中" selected>高中</option>
                            <%}else{%>
                            <option value="高中">高中</option>
                            <%}%>
                            <%if(nf.getEdu().equals("初中")){%>
                            <option value="初中" selected>初中</option>
                            <%}else{%>
                            <option value="初中">初中</option>
                            <%}%>
                            <%if(nf.getEdu().equals("初中")){%>
                            <option value="初中" selected>初中</option>
                            <%}else{%>
                            <option value="初中">初中</option>
                            <%}%>
                            <%if(nf.getEdu().equals("小学")){%>
                            <option value="小学" selected>小学</option>
                            <%}else{%>
                            <option value="小学">小学</option>
                            <%}%>
                            <%if(nf.getEdu().equals("其它")){%>
                            <option value="其它" selected>其它</option>
                            <%}else{%>
                            <option value="其它">其它</option>
                            <%}%>
                        </select>
                    </td>
                </tr>
                <tr>
                <tr>
                    <td>用户职位</td>
                    <td>
                        <select name="work" size="1">
                            <%if(nf.getWork().equals("董事长")){%>
                            <option value="董事长" selected>董事长</option>
                            <%}else{%>
                            <option value="董事长">董事长</option>
                            <%}%>
                            <%if(nf.getWork().equals("总经理")){%>
                            <option value="总经理" selected>总经理</option>
                            <%}else{%>
                            <option value="总经理">总经理</option>
                            <%}%>
                            <%if(nf.getWork().equals("经理")){%>
                            <option value="经理" selected>经理</option>
                            <%}else{%>
                            <option value="经理">经理</option>
                            <%}%>
                            <%if(nf.getWork().equals("主管")){%>
                            <option value="主管" selected>主管</option>
                            <%}else{%>
                            <option value="主管">主管</option>
                            <%}%>
                            <%if(nf.getWork().equals("组长")){%>
                            <option value="组长" selected>组长</option>
                            <%}else{%>
                            <option value="组长">组长</option>
                            <%}%>
                            <%if(nf.getWork().equals("经理")){%>
                            <option value="班长" selected>班长</option>
                            <%}else{%>
                            <option value="班长">班长</option>
                            <%}%>
                            <%if(nf.getWork().equals("员工")){%>
                            <option value="员工" selected>员工</option>
                            <%}else{%>
                            <option value="员工">员工</option>
                            <%}%>
                            <%if(nf.getWork().equals("实习生")){%>
                            <option value="实习生" selected>实习生</option>
                            <%}else{%>
                            <option value="实习生">实习生</option>
                            <%}%>
                            <%if(nf.getWork().equals("其它")){%>
                            <option value="其它" selected>其它</option>
                            <%}else{%>
                            <option value="其它">其它</option>
                            <%}%>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>基本月薪</td>
                    <td><input style="width: 60px;" required="required" value="<%=nf.getMonthPay()%>" type="text" name="monthPay"/></td>
                </tr>
                <tr>
                    <td>用户权限</td>
                    <td>
                        <select name="level" size="1">
                            <%if(nf.getLevel().equals("管理员")){%>
                            <option value="管理员" selected>管理员</option>
                            <%}else{%>
                            <option value="管理员">管理员</option>
                            <%}%>
                            <%if(nf.getLevel().equals("员工")){%>
                            <option value="员工" selected>员工</option>
                            <%}else{%>
                            <option value="员工">员工</option>
                            <%}%>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <input type="submit" value="确 定" size="12">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="reset" value="清 除" size="12">
                    </td>
                </tr>
                <%
                    }
                %>
            </table>
        </form>
        <br>
    </div>
    <%@include file="searchStaff.jsp" %>
    <br>
    <table cellspacing="0" cellpadding="0" style="width: 99%;" align="center">
        <%
            if(staffslist==null||staffslist.size()==0){
        %>
        <div align="center">
            <h1>公司还没有任何员工！</h1>
        </div>
        <%
        }
        else{
        %>
            <table border="2" cellspacing="0" cellpadding="0" style="width: 99%;" align="center">
                <tr>
                    <th>账号</th>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>身份证</th>
                    <th>民族</th>
                    <th>学历</th>
                    <th>职位</th>
                    <th>基本月薪</th>
                    <th>电话</th>
                    <th>地址</th>
                    <th>邮箱</th>
                    <th>权限</th>
                    <th>操作</th>
                </tr>
            </table>
            <table id="pageMain" cellspacing="0" cellpadding="0" style="width: 99%;" align="center">
        <%
            for(int i=staffslist.size()-1;i>=0;i--){
                StaffBean ff=(StaffBean)staffslist.get(i);
                if(search){
                    if(!ff.getLevel().equals(level)&&!level.equals("全部")) continue;
                    if(!ff.getWork().equals(work)&&!work.equals("全部")) continue;
                    if(!ff.getEdu().equals(edu)&&!edu.equals("全部")) continue;
                }
        %>
        <tr class="hoverTr">
            <td><%=ff.getUserName()%></td>
            <td><%=ff.getName()%></td>
            <td><%=ff.getSex()%></td>
            <td><%=ff.getIdCard()%></td>
            <td><%=ff.getNation()%></td>
            <td><%=ff.getEdu()%></td>
            <td><%=ff.getWork()%></td>
            <td><%=ff.getMonthPay()%></td>
            <td><%=ff.getPhone()%></td>
            <td><%=ff.getPlace()%></td>
            <td><%=ff.getEmail()%></td>
            <td><%=ff.getLevel()%></td>
            <td><a href="http://localhost:8080/staffManager/updateStaff.jsp?userName=<%=ff.getUserName()%>">修改</a></td>
        </tr>
        <%
                }
            }
        %>
    </table>
</body>
<%@include file="../page.jsp" %>
</html>
<script src="../JS/update.js"></script>
<script>
    window.onload=function () {
        if(getArgs("userName")!=null){
            showUpdate();
        }
    }
</script>
